package com.ruoyi.web.purchase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.purchase.domain.Rdrecords01;
import com.ruoyi.web.purchase.service.IRdrecords01Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购子表Controller
 * 
 * @author czr
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/search/rdrecords01")
public class Rdrecords01Controller extends BaseController
{
    @Autowired
    private IRdrecords01Service rdrecords01Service;

    /**
     * 查询采购子表列表
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:list')")
    @GetMapping("/list")
    public TableDataInfo list(Rdrecords01 rdrecords01)
    {
        startPage();
        List<Rdrecords01> list = rdrecords01Service.selectRdrecords01List(rdrecords01);
        return getDataTable(list);
    }

    /**
     * 导出采购子表列表
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:export')")
    @Log(title = "采购子表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Rdrecords01 rdrecords01)
    {
        List<Rdrecords01> list = rdrecords01Service.selectRdrecords01List(rdrecords01);
        ExcelUtil<Rdrecords01> util = new ExcelUtil<Rdrecords01>(Rdrecords01.class);
        util.exportExcel(response, list, "采购子表数据");
    }

    /**
     * 获取采购子表详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:query')")
    @GetMapping(value = "/{AutoID}")
    public AjaxResult getInfo(@PathVariable("AutoID") Long AutoID)
    {
        return success(rdrecords01Service.selectRdrecords01ByAutoID(AutoID));
    }

    /**
     * 新增采购子表
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:add')")
    @Log(title = "采购子表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Rdrecords01 rdrecords01)
    {
        return toAjax(rdrecords01Service.insertRdrecords01(rdrecords01));
    }

    /**
     * 修改采购子表
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:edit')")
    @Log(title = "采购子表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Rdrecords01 rdrecords01)
    {
        return toAjax(rdrecords01Service.updateRdrecords01(rdrecords01));
    }

    /**
     * 删除采购子表
     */
    @PreAuthorize("@ss.hasPermi('search:rdrecords01:remove')")
    @Log(title = "采购子表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{AutoIDs}")
    public AjaxResult remove(@PathVariable Long[] AutoIDs)
    {
        return toAjax(rdrecords01Service.deleteRdrecords01ByAutoIDs(AutoIDs));
    }
}
